/*
Copyright © 2025 NAME HERE <EMAIL ADDRESS>

*/
package cmd

import (
	"fmt"
    "github.com/shirou/gopsutil/mem"
	"github.com/spf13/cobra"
)

// memCmd represents the mem command
var memCmd = &cobra.Command{
	Use:   "mem",
	Short: "A brief description of your command",
	Long: `A longer `,
	Run: func(cmd *cobra.Command, args []string) {
		v, _ := mem.VirtualMemory()  // 自动适配 Linux 系统
        fmt.Printf("总内存: %.2f GB\n", float64(v.Total)/1e9)
        fmt.Printf("已用内存: %.2f GB\n", float64(v.Used)/1e9)
    	fmt.Printf("可用内存: %.2f GB\n", float64(v.Available)/1e9)
	},
}

func init() {
	rootCmd.AddCommand(memCmd)

}
